home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!news
- From: jhewett@ix.netcom.com (Jerry Hewett)
- Newsgroups: comp.lang.c++
- Subject: Re: screen->metafile
- Date: Fri, 05 Apr 96 01:15:00 GMT
- Organization: Netcom
- Message-ID: <N.040496.171500.24@ix.netcom.com>
- References: <pboysen.828654012@abc.cc.iastate.edu>
- NNTP-Posting-Host: tem-ca1-16.ix.netcom.com
- X-NETCOM-Date: Thu Apr 04 7:18:35 PM CST 1996
- X-Newsreader: Quarterdeck Message Center [2.00]
-
- On 4/4/96 1:40PM, in message <pboysen.828654012@abc.cc.iastate.edu>, Pete
- Boysen <pboysen@iastate.edu> wrote:
-
- > I would like to copy a rectangular bitmap defined by rect to a metaDC
- > however the BitBlt function always fails. How can I do this? Do I need
- > to use device-independent bitmaps? Below is the code I am currently using
- > to do this:
-
- I was trying to figure out how to use DIB's myself just a couple of weeks ago,
- and came across this article on one of the MS Developer Network CD's. Hope
- this at least points you in the right direction! :-)
-
- ----<snip>----
-
- [excerpted from: _DIBs And Their Use_ by Ron Gery; MSDN Technical Article]
-
- SetDIBitsToDevice
-
- SetDIBitsToDevice allows an application to set a DIB directly to a device
- surface. Because this function is a holdout from early development, its
- interface is not as polished as it could be. StretchDIBits is a far more
- powerful function than SetDIBitsToDevice. StretchDIBits does all that
- SetDIBitsToDevice does and has a nicer interface. SetDIBitsToDevice is
- limited in the way it handles metafiles because it does not scale, and
- banding with the nStartScan and nNumScans parameters is nontrivial at best.
- StretchDIBits does not allow the banding.
-
- The following code performs the SetDIBitsToDevice functionality on the full
- bitmap (no banding) using StretchDIBits:
-
- StretchDIBits(hDC, x, y, (WORD)lpInfo->biWidth,
- (WORD)lpInfo->biHeight, 0, 0, (WORD)lpInfo->biWidth,
- (WORD)lpInfo->biHeight, lpBits, lpInfo, DIB_RGB_COLORS,
- SRCCOPY)
-
- Assuming that nStartScan is set to 0 and that nNumScans is set to
- lpInfo->biHeight (that is, no banding), the function is basically a BitBlt
- with SRCCOPY as the ROP and with a DIB as the source. SrcX and SrcY are in
- the DIB's space and are therefore upside down in relation to the DC (Y = 0
- is at the bottom of the image).
-
- Dealing with the upside-down DIB is tricky when doing a partial setting.
- For example, if an application wants to get the bottom third of a DIB that
- is w by h pixels to the device at (x,y), the call would look something like
- the following:
-
- SetDIBitsToDevice(hDC, x, y, w, h/3, 0, h/3, 0,
- (WORD)lpInfo->biHeight, lpBits, lpInfo, DIB_RGB_COLORS);
-
- A device-dependent bitmap would have a SrcY of 2h/3 for the bottom third,
- but with the upside-down system of the DIB, a SrcY of h/3 points to the
- proper place relative to Windows coordinates.
-
- ----<snip>----
-
- There's a lot more good, detailed information in the article itself, but the
- long and short of it is that you apparently need to use something like
- StretchDIBits instead of BitBlt to move a bitmapped region into a metafile.
-
- I'm guessing this article is available somewhere on the MS website. If you
- can't locate it let me know.
-
- Jerry H.
-
-
-